home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Trading on the Edge
/
Trading On The Edge - CD-ROM Toolkit (Wayzata Technology)(2031)(1994).bin
/
pc
/
mac_file
/
vendor_d
/
neuralwa
/
nw2v50
/
uio_if_d.c
< prev
next >
Wrap
Text File
|
1993-08-23
|
6KB
|
178 lines
/*******************************************************************/
/* */
/* servif_d.c - SERVor InterFace platform Dependent (.) Code */
/* Authors: John C. Fairman and John Guiver Dec 7, 1990 */
/* Copyright 1990 by Neuralware Inc. */
/* */
/* $Author : $ */
/* $Date : $ */
/* $Source : $ */
/* $Revision : $ */
/* $Log : $ */
/* */
/*******************************************************************/
#define UIO_IF_D
#include "host.h"
#define UIO_SERVER 1
#define SERVER_EMULATOR_FILE 2
#define SKIP_COMPAT_DATA 1
#include "userutl.h"
#include "uio_strc.h"
#include "uio_tran.h"
#include "uio_if_i.pro"
#include "uio_if_d.pro"
#include <SetUpA4.h>
#include "macuio.redef"
IMPORT NINT IORtnC;
typedef long int (*LProcPtr)( ); /* Think C ProcPtr returns a short */
typedef int (*myProcPtr)( );
LProcPtr stdio_funcs[MIO_MAX]; /* Host stdio/stdlib function pointers */
myProcPtr Receive_request; /* Address for requesting host */
/* Glue routines for redirecting calls to Host */
#define GLUE_ROUTINE(rout_num,\
type, ptr, name, \
t1,p1,n1,t2,p2,n2,t3,p3,n3,t4,p4,n4) \
type ptr name( n1,n2,n3,n4) \
t1 p1 n1;\
t2 p2 n2;\
t3 p3 n3;\
t4 p4 n4;\
{\
type ptr ret_cde;\
ret_cde = (type ptr)stdio_funcs[rout_num]( (t1 p1)n1,\
(t2 p2)n2,\
(t3 p3)n3,\
(t4 p4)n4 );\
return ret_cde;\
}
GLUE_ROUTINE(MIO_fseek,int, ,io_fseek,FILE,*,fp,long, ,offset,long, ,whence,int,,n4)
GLUE_ROUTINE(MIO_ftell,long, ,io_ftell,FILE,*,fp,int,,n2,int,,n3,int,,n4)
GLUE_ROUTINE(MIO_fopen,FILE,*,io_fopen,char,*,filename,char,*,mode,int,,n3,int,,n4)
GLUE_ROUTINE(MIO_freopen,FILE,*,io_freopen,char,*,filename,char,*,mode,FILE,*,stream,int,,n4)
GLUE_ROUTINE(MIO_fclose,int, ,io_fclose,FILE,*,fp,int,,n2,int,,n3,int,,n4)
GLUE_ROUTINE(MIO_remove,int, ,io_remove,char,*,filename,int,,n2,int,,n3,int,,n4)
GLUE_ROUTINE(MIO_rename,int, ,io_rename,char,*,old,char,*,new,int,,n3,int,,n4)
GLUE_ROUTINE(MIO_tmpnam,char,*,io_tmpnam,char,*,s,int,,n2,int,,n3,int,,n4)
GLUE_ROUTINE(MIO_fflush,int, ,io_fflush,FILE,*,stream,int,,n2,int,,n3,int,,n4)
GLUE_ROUTINE(MIO_setvbuf,int, ,io_setvbuf,FILE,*,stream,char,*,buf,long,,mode,size_t,,size)
GLUE_ROUTINE(MIO_fgetc,int, ,io_fgetc,FILE,*,stream,int,,n2,int,,n3,int,,n4)
GLUE_ROUTINE(MIO_fgets,char,*,io_fgets,char,*,s,long,,n,FILE,*,stream,int,,n4)
GLUE_ROUTINE(MIO_fputc,int, ,io_fputc,long,,c,FILE,*,stream,int,,n3,int,,n4)
GLUE_ROUTINE(MIO_fputs,int, ,io_fputs,char,*,s,FILE,*,stream,int,,n3,int,,n4)
GLUE_ROUTINE(MIO_ungetc,int, ,io_ungetc,long,,c,FILE,*,stream,int,,n3,int,,n4)
GLUE_ROUTINE(MIO_fread,size_t, ,io_fread,void,*,ptr,size_t,,size,size_t,,nmemb,FILE,*,stream)
GLUE_ROUTINE(MIO_fwrite,size_t, ,io_fwrite,void,*,ptr,size_t,,size,size_t,,nmemb,FILE,*,stream)
GLUE_ROUTINE(MIO_fgetpos,int, ,io_fgetpos,FILE,*,stream,fpos_t,*,pos,int,,n3,int,,n4)
GLUE_ROUTINE(MIO_fsetpos,int, ,io_fsetpos,FILE,*,stream,fpos_t,*,pos,int,,n3,int,,n4)
GLUE_ROUTINE(MIO_calloc,void,*,io_calloc,size_t,,nmemb,size_t,,size,int,,n3,int,,n4)
GLUE_ROUTINE(MIO_malloc,void,*,io_malloc,size_t,,size,int,,n2,int,,n3,int,,n4)
GLUE_ROUTINE(MIO_realloc,void,*,io_realloc,void,*,ptr,size_t,,size,int,,n3,int,,n4)
#define GLUE_VOIDRTN(rout_num, name, t1,p1,n1,t2,p2,n2 ) \
void name( n1,n2) \
t1 p1 n1;\
t2 p2 n2;\
{\
stdio_funcs[rout_num]( (t1 p1)n1,(t2 p2)n2);\
}
GLUE_VOIDRTN(MIO_setbuf,io_setbuf,FILE,*,stream,char,*,buf)
GLUE_VOIDRTN(MIO_free,io_free,void,*,ptr,int,,n2)
GLUE_VOIDRTN(MIO_rewind,io_rewind,FILE,*,stream,int,,n2)
FILE *io_tmpfile( void )
{
stdio_funcs[MIO_tmpfile]( );
}
#define GLUE_FMT(rout_num, name, type)\
int name( ptr, format, a1,a2,a3,a4,a5,a6,a7,a8,a9,\
b1,b2,b3,b4,b5,b6,b7,b8,b9,\
c1,c2,c3,c4,c5)\
type *ptr;\
char *format;\
int a1,a2,a3,a4,a5,a6,a7,a8,a9;\
int b1,b2,b3,b4,b5,b6,b7,b8,b9;\
int c1,c2,c3,c4,c5;\
{\
int ret_cde;\
ret_cde = (int)stdio_funcs[rout_num]( (type *)ptr, format,\
a1,a2,a3,a4,a5,a6,a7,a8,a9,\
b1,b2,b3,b4,b5,b6,b7,b8,b9,\
c1,c2,c3,c4,c5);\
return ret_cde;\
}
GLUE_FMT(MIO_sprintf, io_sprintf, char)
GLUE_FMT(MIO_fprintf, io_fprintf, FILE)
GLUE_FMT(MIO_sscanf, io_sscanf, char)
GLUE_FMT(MIO_fscanf, io_fscanf, FILE)
/* FUNCTION */
EXPORT VOID Send_request()
{
Receive_request();
SetUpA4(); /* possibly A4 has been corrupted */
asm{ adda.l #4,sp } /* SetUpA4 pushes old unwanted A4 onto the stack; adjust SP */
}
/**/
/* FUNCTION */
EXPORT NINT Receive_command(dtp)
DATA_TRANSFER_AREA_T *dtp; /* Data transfer ptr */
{
RPC_AREA_T *rpc;
Data_transfer_ptr = dtp;
rpc = &(dtp)->RPC_area;
if (rpc->request == (BUFFER_INT) CMD_CREATE) {
{
NINT wx;
/* Tell master about size of double so we can check consistency */
(rpc->all_arg_lists.createcmd).szof_uio_dbl = sizeof(long double);
/* Set up NWorks function addresses for server requests */
Receive_request = (myProcPtr) (rpc->all_arg_lists.createcmd).Receive_request;
for (wx=0; wx< MIO_MAX; wx++) stdio_funcs[wx] =
(LProcPtr) (rpc->all_arg_lists.createcmd).stdio_funcs[wx];
}
rpc->request = (BUFFER_INT) REQ_ACKNOWLEDGE;
} else {
Handle_command();
}
return(1);
}
long main(dtp)
DATA_TRANSFER_AREA_T *dtp; /* Data transfer ptr */
{
RememberA0(); /* to access resource global variables */
SetUpA4();
Receive_command( dtp );
RestoreA4( );
}
/**/
/* FUNCTION */
EXPORT VOID UIO_server_error(err_id)
NINT err_id;
{
Data_transfer_ptr->RPC_area.request = err_id;
}